#!/bin/sh

. ../eval_tools.sh

HEADER "extending agent functionality with extend"

SKIPIF DISABLE_SNMPV2C
SKIPIFNOT USING_AGENT_EXTEND_MODULE

# make sure snmpget can be executed
SNMPGET="${SNMP_UPDIR}/apps/snmpget"
[ -x "$SNMPGET" ] || SKIP

snmp_version=v2c
TESTCOMMUNITY=testcommunity
. ./Sv2cconfig

#
# Begin test
#

CONFIGAGENT extend hello /usr/bin/env echo hello_world

STARTAGENT

# NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."hello" = STRING: "hello_world"
CAPTURE "$SNMPGET $SNMP_FLAGS -$snmp_version -c $TESTCOMMUNITY $SNMP_TEST_DEST$SNMP_SNMPD_PORT 1.3.6.1.4.1.8072.1.3.2.3.1.1.\"hello\""
CHECKORDIE "hello_world"

#NET-SNMP-EXTEND-MIB::nsExtendOutputFull."hello" = STRING: "hello_world"
CAPTURE "$SNMPGET $SNMP_FLAGS -$snmp_version -c $TESTCOMMUNITY $SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.4.1.8072.1.3.2.3.1.2.\"hello\""
CHECKORDIE "hello_world"

#NET-SNMP-EXTEND-MIB::nsExtendOutLine."hello".1 = STRING: "hello_world"
CAPTURE "$SNMPGET $SNMP_FLAGS -$snmp_version -c $TESTCOMMUNITY $SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.4.1.8072.1.3.2.4.1.2.\"hello\".1"
CHECKORDIE "hello_world"

#NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."hello" = INTEGER: 1
CAPTURE "$SNMPGET $SNMP_FLAGS -$snmp_version -c $TESTCOMMUNITY $SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.4.1.8072.1.3.2.3.1.3.\"hello\""
CHECKORDIE "INTEGER: 1"

#NET-SNMP-EXTEND-MIB::nsExtendResult."hello" = INTEGER: 0
CAPTURE "$SNMPGET $SNMP_FLAGS -$snmp_version -c $TESTCOMMUNITY $SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.4.1.8072.1.3.2.3.1.4.\"hello\""
CHECKORDIE "INTEGER: 0"

STOPAGENT
FINISHED
